<?php

class Categories extends MX_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->lang->load('error', $this->public_model->getLanguage());
    }
    function deals($category_id = null)
    {
        if ($category_id != null)
        {
            $content = modules::run('deal/all_deals', $category_id);
            Template::display($content);	
        }
        else
        {
            echo Modules::run('common/error_404');
        }
    }
    function frontback()
    {
        $data = array();   
        $options = array(
            'enable'=>ENABLED,
            //'limit'=>5,
            //'offset'=>0
        );
        $city_session = $this->session->userdata('city_session');
        $data['categories'] = $this->public_model->getCategories($options);
        for($i=0;$i<count($data['categories']); $i++)
        {
            $options = array(
                'city_id' => $city_session,
                'category_id' => $data['categories'][$i]->id,
            );
            $data['categories'][$i]->number_of_deal = $this->public_model->getCountDeal($options);   
        }
         
        //$data['categories_more'] = $this->public_model->getCategories($options);
        
        $this->load->view('categories_frontback_view', $data);              
    }
  
}
